package top.laoshuzi.android.tts.service;

import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.os.ServiceManager;
import android.support.annotation.RequiresApi;
import top.laoshuzi.android.tts.core.TtsManager;

public class TtsService extends Service {


    private TtsServiceImpl ttsService;

    public TtsService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();

        ttsService = new TtsServiceImpl(this);
        ttsService.open();

        ServiceManager.addService(TtsManager.TTS_SERVICE_NAME, ttsService);
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    @Override
    public void onDestroy() {
        ttsService.shutdown();
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return ServiceManager.getService(TtsManager.TTS_SERVICE_NAME);
    }
}
